package com.zjp.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("order")
public class OrderController {
    private static final Logger logger = LoggerFactory.getLogger(OrderController.class);

    /*@Autowired
    DelayOrderService delayOrderService;
    @Resource
    OrderMapper orderMapper;
    @Autowired
    RocketMQTemplate rocketMQTemplate;
    @Autowired
    RocketMQConfig rocketMQConfig;
    @Autowired
    OrderService orderService;

    @GetMapping("addDelayOrder")
    public ResponseEntity<Order> delayOrder() {
        Order order = delayOrderService.addOrder();
        if (orderMapper.insert(order) == 1) {
            Message<String> build = MessageBuilder.withPayload(JSONUtil.parse(order).toString()).build();
            // delayTimeLevel：(1~18个等级)"1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h"
            String delayOrderTopic = rocketMQConfig.getDelayOrderTopic();
            SendResult sendResult = rocketMQTemplate.syncSend(delayOrderTopic, build, 3000, 2);
            if (sendResult.getSendStatus() == SendStatus.SEND_OK) {
                logger.info("发送延迟订单消息-{}", DateUtil.now());
                return ResponseEntity.ok(order);
            }
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }

    @GetMapping("listOrder")
    public ResponseEntity<List<Order>> listOrder() {
        return ResponseEntity.ok(CollUtil.emptyIfNull(orderMapper.selectList(null)));
    }
    @GetMapping("send")
    public ResponseEntity<String> send() {
        orderService.send();

        return ResponseEntity.ok("success");
    }*/




}
